/*
Copyright (C) 2009-2010 wxLauncher Team

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

#ifndef PLATFORMPROFILEMANAGER_H
#define PLATFORMPROFILEMANAGER_H
#include <wx/fileconf.h>
#include <wx/filename.h>
#include "apis/ProfileManager.h"
#include "generated/configure_launcher.h"

bool CreateWritablePath(wxFileName &path);

ProMan::RegistryCodes RegistryPushProfile(wxFileConfig *cfg);
ProMan::RegistryCodes RegistryPullProfile(wxFileConfig *cfg);

ProMan::RegistryCodes FilePushProfile(wxFileConfig *cfg);
ProMan::RegistryCodes FilePullProfile(wxFileConfig *cfg);

ProMan::RegistryCodes PushCmdlineFSO(wxFileConfig *cfg);


// Get the directory where fs2_open stores per-user configuration files on this
// platform.
inline wxFileName GetPlatformDefaultConfigFilePath() {
	wxFileName path;
#if IS_WIN32
	path.AssignDir(wxStandardPaths::Get().GetUserConfigDir());
	path.AppendDir(_T("FS2 Open"));
#elif IS_APPLE
	path.AssignHomeDir();
	path.AppendDir(_T("Library"));
	path.AppendDir(_T("FS2_Open"));
#elif IS_LINUX
	path.AssignHomeDir();
	path.AppendDir(_T(".fs2_open"));
#else
#	error "One of IS_WIN32, IS_LINUX, IS_APPLE must evaluate to true"
#endif

	wxASSERT_MSG(outFileName.Normalize(),
		wxString::Format(_T("Unable to normalize PlatformDefaultConfigFilePath (%s)"),
		path.GetFullPath().c_str()));

	if(!CreateWritablePath(path)) {
		wxLogError(_T("Unable to write to PlatformDefaultConfigFilePath (%s)"),
		path.GetFullPath().c_str());
		return wxFileName();
	}

	return path;
}

#endif
